//
//  StepperBootcamp.swift
//  FCSwiftUI
//
//  Created by 哲思 on 2023/3/2.
//

import SwiftUI

struct StepperBootcamp: View {
    @State var stepperValue: Int = 0
    @State var widthIncrement: CGFloat = 0
    
    var body: some View {
        VStack {
            Stepper("Stepper: \(stepperValue)", value: $stepperValue)
            
            RoundedRectangle(cornerRadius: 25.0)
                .frame(width: 100+widthIncrement, height: 100)
            
            Stepper("Stepper2:") {
                incrementWidth(50)
            } onDecrement: {
                incrementWidth(-50)
            }
        }
        .padding(20)
    }
    
    func incrementWidth(_ amount: CGFloat) {
        withAnimation(.easeInOut) {
            widthIncrement += amount
        }
    }
}

struct StepperBootcamp_Previews: PreviewProvider {
    static var previews: some View {
        StepperBootcamp()
    }
}
